Skip to content

fix(recap): surface real auth/network errors on first run#1168

Merged
peyton-alt merged 3 commits into
mainfrom
review-fix-2
May 11, 2026
Merged

fix(recap): surface real auth/network errors on first run#1168
peyton-alt merged 3 commits into
mainfrom
review-fix-2

Conversation

@peyton-alt
Copy link
Copy Markdown
Contributor

@peyton-alt peyton-alt commented May 8, 2026

https://entire.io/gh/entireio/cli/trails/342

Summary

  • The auth pre-check in runRecap collapsed three distinct failure modes (missing token, keyring read error, insecure base URL) into one Sign in with \entire login`message, with the real error swallowed byNewSilentError. Flags appeared broken on first run because the function exited before any line that consumed --week, --agent`, etc.
  • Replaced the gating call with a newRecapClient helper that builds the client even with an empty token, so FetchMeRecap always runs and surfaces the actual cause via the existing recapLoadErrorMessage mapping (401 → "Run entire login to re-authenticate.", 4xx/5xx → specific guidance).
  • The insecure-URL check stays but only when a token exists, with a friendlier message that names the offending env var and the fix.
  • Split DNS NXDOMAIN out of the generic network-error path so a misconfigured ENTIRE_API_BASE_URL says "Could not resolve API host…" instead of blaming the user's internet connection.

Test plan

  • mise run check passes (fmt + lint + unit + integration + canary E2E, ~144s)
  • Manual: real logged-in entire recap --static --day renders data
  • Manual: fake host (NXDOMAIN) → "Could not resolve API host …" (not "check your internet")
  • Manual: http:// URL without --insecure-http-auth → friendly env-var message (not "sign in")
  • Manual: mock 401 server → "Run entire login to re-authenticate." for --day/--week/--month/--90
  • New test TestRecapLoadErrorMessage_DNSNotFound covers NXDOMAIN
  • Verify against staging entire.io if available

🤖 Generated with Claude Code


Note

Medium Risk
Adjusts entire recap authentication/client initialization and error messaging, which can affect how secure/insecure API base URLs are handled and what users see on failures. While scoped to the recap command, regressions could change login prompting or mask real connectivity issues.

Overview
entire recap no longer preemptively fails when the auth token is missing or unreadable; it now builds an API client via newRecapClient (even with an empty token) so the recap fetch runs and surfaces the actual 401/auth failure through existing error mapping.

Insecure http:// ENTIRE_API_BASE_URL handling is tightened to only block when a token exists (unless --insecure-http-auth is set) and now prints a clearer, env-var-specific remediation message.

Recap error messaging now distinguishes DNS NXDOMAIN from generic network failures, returning a targeted “Could not resolve API host…” hint, with a new unit test covering the NXDOMAIN case.

Reviewed by Cursor Bugbot for commit 98b4106. Configure here.

The auth pre-check in runRecap collapsed three distinct failure modes
(missing token, keyring read error, insecure base URL) into a single
"Sign in with `entire login`" message, with the real error swallowed by
NewSilentError. This made flags appear broken on first run because the
function exited before any line that consumed --week, --agent, etc.

Replace the gating call with a newRecapClient helper that builds the
client even with an empty token, so FetchMeRecap always runs and surfaces
the actual cause via the existing recapLoadErrorMessage mapping (401 →
"Run `entire login` to re-authenticate.", 4xx/5xx → specific guidance).
The insecure-URL check stays but only when a token exists, with a
friendlier message that names the offending env var and the fix.

Also split DNS NXDOMAIN out of the generic network-error path so a
misconfigured ENTIRE_API_BASE_URL says "Could not resolve API host..."
instead of blaming the user's internet connection.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Entire-Checkpoint: d534f23017c5
Copilot AI review requested due to automatic review settings May 8, 2026 21:38
@peyton-alt peyton-alt requested a review from a team as a code owner May 8, 2026 21:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates entire recap startup/auth behavior so first-run failures surface the real underlying API/auth/network error (instead of being collapsed into a generic “sign in” message), and improves network error messaging by distinguishing DNS NXDOMAIN from general connectivity issues.

Changes:

  • Replace the early auth “gate” with a newRecapClient helper that allows recap fetch to run (even with an empty token) and lets existing error mapping handle 401/4xx/5xx cases.
  • Improve insecure base URL handling to produce a friendlier, more actionable message when auth would be sent over HTTP.
  • Add explicit NXDOMAIN detection to show a “Could not resolve API host…” message, plus a unit test covering it.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
cmd/entire/cli/recap.go Builds recap API client without gating on missing token; special-cases insecure HTTP auth error messaging.
cmd/entire/cli/recap_errors.go Adds NXDOMAIN detection + tailored DNS error message ahead of generic network error messaging.
cmd/entire/cli/recap_test.go Adds TestRecapLoadErrorMessage_DNSNotFound to validate the new NXDOMAIN message behavior.

Comment thread cmd/entire/cli/recap.go Outdated
Address Copilot review on #1168: newRecapClient was discarding the error
from auth.LookupCurrentToken, which silently turned a keyring read
failure (locked, permission denied, etc.) into a "no token" state.
That re-introduced the same collapsed-error UX the PR set out to fix —
the user would be told to run `entire login`, which can't help when the
keyring itself is the problem.

Wrap the underlying error in a *keyringReadError (preserving the cause
via errors.As) and route it in runRecap to a targeted message that
states the keyring is the problem and that re-login is unlikely to
help. Truly-missing tokens (keyring.ErrNotFound resolves to "", nil
upstream) still flow through to FetchMeRecap and the existing 401 →
"Run `entire login` to re-authenticate." mapping.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Entire-Checkpoint: 60d4f6868ab0
Copy link
Copy Markdown
Collaborator

@Soph Soph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look

@peyton-alt peyton-alt enabled auto-merge (squash) May 11, 2026 17:21
@peyton-alt peyton-alt merged commit 2f7901d into main May 11, 2026
9 checks passed
@peyton-alt peyton-alt deleted the review-fix-2 branch May 11, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants